package lib

import "sort"

func init() {
	Probs = append(Probs, Problem{
		Num:         274,
		Discription: "H指数",
		Level:       2,
		Labels: map[string]int{
			"排序": 1,
		},
	})
}

func HIndex(citations []int) int {
	sort.Slice(citations, func(i, j int) bool {
		return citations[i] > citations[j]
	})

	for i := range citations {
		if i+1 > citations[i] {
			return i
		}
	}

	//注意全部论文都有效的情况
	return len(citations)
}
